﻿// JavaScript Document
//用户登录
function UserLogin(url)
{	
	//alert('debug');
	var warn=document.getElementById('warn');
	var username=document.getElementById('txtUsername').value;
	if(username==null ||username=="")
	{
		warn.innerText="您还没有填写账号";
		return;
	}
	var pwd=document.getElementById('txtPwd').value;
	//alert('debug2');
	if(pwd==null ||pwd=="")
	{
		warn.innerText="您还没有填写密码";
		return;
	}
	
	url+="?action=GetUser";
	var para="username="+username;
	para+="&password="+pwd;
	var response=SendPostRequest(url,para);	
	alert(response); 
	if(response=="false")
	{
		warn.innerText="登录失败！用户名或密码错误！";
		return response;
	}
	else
	{
		document.cookie="username"+"="+username+";path=/;";
		document.cookie="userID"+"="+response+";path=/;";
		if (username!=null && username!="")
		{
			alert('Welcome again '+username+'!')
		}
		return response;

	}
	
}


//用户退出
function UserLogout(url)
{
	url+="?action=Logout";
	var para=null;
	var response=SendPostRequest(url,para);	
}
